package com.tourism.home.controller.page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class IndexController {

    @Autowired
    HttpServletRequest httpServletRequest;

    @GetMapping({"/","/index",})
    String index(){
        return "/index";
    }
    @GetMapping({"/off"})
    String off(){
        return "/off";
    }

    @GetMapping("/publish")
    String publish(){
        return "/publish";
    }

    @GetMapping("/grade")
    String grade(){
        return "/grade";
    }

    //ok
    @GetMapping("/post/{id}")
    String post(@PathVariable("id") Integer id){
        HttpSession session = httpServletRequest.getSession();
        session.setAttribute("post_id",id);
        return "/post";
    }

    //ok
    @GetMapping("/forum")
    String forum(){
        return "/forum";
    }

    //ok
    @GetMapping("/hot")
    String hot(){
        return "/hot";
    }

    //ok
    @GetMapping("/safe")
    String safe(){
        return "/safe";
    }

    //ok
    @GetMapping("/user")
    public String user(){
        return "/user";
    }

    //ok
    @GetMapping("/user/set")
    public String set(){
        return "/set";
    }

    //ok
    @GetMapping("/repo")
    public String repo(){
        return "/repo";
    }

    //ok
    @GetMapping("/visitor/{id}")
    public String visitor(@PathVariable("id") Integer id){
        HttpSession session = httpServletRequest.getSession();
        session.setAttribute("visitor_id",id);
        return "/visitor";
    }

    //ok
    @GetMapping("/collection")
    public String collection(){
        return "/collection";
    }
}
